/**
 * 
 */
package com.ternnetwork.batch.callback;

import java.io.IOException;

import javax.xml.stream.XMLEventFactory;
import javax.xml.stream.XMLEventWriter;


import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.listener.StepExecutionListenerSupport;
import org.springframework.batch.item.xml.StaxWriterCallback;


public class FooterStaxWriterCallback extends StepExecutionListenerSupport
		implements StaxWriterCallback {
	private StepExecution stepExecution;
	
	
	public void write(XMLEventWriter writer) throws IOException {
		XMLEventFactory factory = XMLEventFactory.newInstance();
		try {
			
		
			writer.add(factory.createComment("Total write count = "+ stepExecution.getWriteCount() + ";credit 201310 end."));
			
			//writer.add(factory.createEndElement("", "", "data"));
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	
	public void beforeStep(StepExecution stepExecution) {
		this.stepExecution = stepExecution;
	}
}
